package com.huigao.access;



import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class DbUtil {

	/**
	 * Access数据库测试连接类
	 * @param args
	 */
	public static void main(String[] args) {

		Connection conn;
		Statement stmt;
		ResultSet rs;
		try{
			conn=DriverManager.getConnection("jdbc:odbc:datatest","","");//这里的user和管理工具中建立的名称对应
			if(conn!=null){
				System.out.println("Access数据库连接成功！");
			}else{
				System.out.println("Access数据库连接失败！");
			}

			stmt=conn.createStatement();
			rs=stmt.executeQuery("select * from lianxi");
			while(rs.next()){
				System.out.println(rs.getString(3));
			}

		}catch(Exception e){
			e.printStackTrace();
		}
	}

}
